package cn.jbolt.ec.spreader;

import cn.jbolt._admin.permission.CheckPermission;
import cn.jbolt._admin.permission.PermissionKey;
import cn.jbolt.base.JBoltBaseController;
import cn.jbolt.common.model.BecSpreader;
import com.jfinal.aop.Inject;
import com.jfinal.plugin.activerecord.Page;

/******************************************
 * @author zedomi
 */
@CheckPermission(PermissionKey.SPREADER_ADMIN)
public class EcSpreaderAuthController extends JBoltBaseController {

    @Inject
    SpreaderService spreaderService;

    /**
     * 分销商管理主页面
     */
    public void index(){
        Page<BecSpreader> page = spreaderService.spreader_paginate(getPageNumber(),getPageSize(),getKeywords());
        keepPara();
        set("pageData",page);
        render("index.html");
    }

    /**
     * 分销商管理拒绝页面
     */
    public void turn_down_reason(){
        Integer id = getInt(0);
        set("spreader",spreaderService.findById(id));
        render("turn_down_reason.html");
    }

    /**
     * 分销商管理拒绝方法
     */
    public void delete_audit_time(){
        Integer id = getInt(0);
        String reason=get("reason");
       renderJson(spreaderService.delete_pass_audited(id,2,reason));

    }

    /**
     * 分销商管理通过方法
     */
    public void pass_spreader(){
        Integer id = getInt(0);
        renderJson(spreaderService.delete_pass_audited(id,1,null));
    }

}
